package DALTests;

import DAO.SimpleAccessor;
import DAO.SimpleAccessorFactory;
import Entities.*;
import Exceptions.InvalidEntityException;
import java.io.FileNotFoundException;
import java.io.IOException;
import java.io.UnsupportedEncodingException;
import java.lang.reflect.InvocationTargetException;
import java.sql.SQLException;
import java.util.LinkedList;
import java.util.logging.Level;
import java.util.logging.Logger;

/**
 * Класс для тестирования слоя данных.
 * @author 647_2
 */
public class DALTester {
    public static void main(String[] args) throws UnsupportedEncodingException, NoSuchFieldException {
        try {
            SimpleAccessor sa = SimpleAccessorFactory.createSimpleAccessor(URL.class);
            URL url = new URL();
            url.set_ID(1);
            url.set_composition(new Composition(1,"",0.0));
            try {
                LinkedList<URL> ll = sa.select(url);

                //url = new URL(2, null, null);

                URL url2 = new URL();
                url2.set_URL("12312313131345555555555555");
                

                System.out.println(sa.delete(url));
            } catch (InvalidEntityException ex) {
                Logger.getLogger(DALTester.class.getName()).log(Level.SEVERE, null, ex);
            } catch (ClassNotFoundException ex) {
                Logger.getLogger(DALTester.class.getName()).log(Level.SEVERE, null, ex);
            } catch (SQLException ex) {
                Logger.getLogger(DALTester.class.getName()).log(Level.SEVERE, null, ex);
            } catch (NoSuchMethodException ex) {
                Logger.getLogger(DALTester.class.getName()).log(Level.SEVERE, null, ex);
            } catch (IllegalAccessException ex) {
                Logger.getLogger(DALTester.class.getName()).log(Level.SEVERE, null, ex);
            } catch (IllegalArgumentException ex) {
                Logger.getLogger(DALTester.class.getName()).log(Level.SEVERE, null, ex);
            } catch (InvocationTargetException ex) {
                Logger.getLogger(DALTester.class.getName()).log(Level.SEVERE, null, ex);
            } catch (InstantiationException ex) {
                Logger.getLogger(DALTester.class.getName()).log(Level.SEVERE, null, ex);
            }
        } catch (FileNotFoundException ex) {
            Logger.getLogger(DALTester.class.getName()).log(Level.SEVERE, null, ex);
        } catch (IOException ex) {
            Logger.getLogger(DALTester.class.getName()).log(Level.SEVERE, null, ex);
        }
    }
}
